package city.spring.modules.material.vo;

import city.spring.action.model.AbstractDeliveryMaterial;
import city.spring.modules.material.entity.MaterialdeliveryMaterialExtEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;

/**
 * @author 谢金婷
 * @date 2020/6/4 0004 16:48
 * @see MaterialdeliveryMaterialExtEntity
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class MaterialdeliveryMaterialVO extends MaterialdeliveryMaterialExtEntity {
    /**
     * 仓库名称
     */
    private String storehouseId;
    /**
     * 物资仓库
     */
    private String sname;

    /**
     * 物资类别
     */
    private String categoryId;

    /**
     * 类别名称
     */
    private String cname;

    /**
     * 物资编码
     */
    private String code;

    /**
     * 物资名称
     */
    private String name;
    /**
     * 计量单位
     */
    private String unitmeasurement;
    /**
     * 单价
     */
    private BigDecimal unitprice;

    /**
     * 出库单
     */
    private String deliveryId;

    /**
     * 转换成出库时所需要的对象
     *
     * @return AbstractPlanUser
     */
    public AbstractDeliveryMaterial<MaterialdeliveryMaterialVO> toDeliveryMaterial() {
        MaterialdeliveryMaterialVO item = this;
        return new AbstractDeliveryMaterial<MaterialdeliveryMaterialVO>() {

            @Override
            public Object getKey() {
                return item.getMaterialId();
            }

            @Override
            public String getName() {
                return item.getName();
            }

            @Override
            public String getCode() {
                return item.getCode();
            }

            @Override
            public String getStorehouseId() {
                return item.getStorehouseId();
            }

            @Override
            public String getSname() {
                return item.getSname();
            }

            @Override
            public String getCategoryId() {
                return item.getCategoryId();
            }

            @Override
            public String getCname() {
                return item.getCname();
            }

            @Override
            public String getUnitmeasurement() {
                return item.getUnitmeasurement();
            }

            @Override
            public BigDecimal getUnitprice() {
                return item.getUnitprice();
            }

            @Override
            public BigDecimal getDeliveryquantity() {
                return item.getDeliveryquantity();
            }

            @Override
            public MaterialdeliveryMaterialVO getObject() {
                return item;
            }
        };
    }
}
